//
//  XKLWebViewController.m
//  GuiZiShouDuanZi
//
//  Created by xmg on 16/5/3.
//  Copyright © 2016年 xiao_kl. All rights reserved.
//

#import "XKLWebViewController.h"
#import "XKLMeItem.h"

@interface XKLWebViewController ()<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIToolbar *HouTui;
@property (weak, nonatomic) IBOutlet UIToolbar *QianJing;
@property (weak, nonatomic) IBOutlet UIToolbar *ShuaiXing;
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIProgressView *progressView;

@end

@implementation XKLWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    [self upWebView];
}

-(void)upWebView{
    self.webView.delegate=self;
    NSURL *url=[NSURL URLWithString:self.item.url];
    
    NSURLRequest *request=[NSURLRequest requestWithURL:url];
    self.title=self.item.name;
    [self.webView loadRequest:request];
}
- (IBAction)qianjinButClick:(id)sender {
    
    [self.webView goForward];
    
}
- (IBAction)houtuiButClick:(id)sender {
    [self.webView goBack];
}
- (IBAction)shuaXing:(id)sender {
    [self.webView reload];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

//-(void)viewDidLayoutSubviews{
//    [super viewDidLayoutSubviews];
////    self.webView.width=ScreenW;
//}

-(void)webViewDidStartLoad:(UIWebView *)webView{
    self.progressView.progress+=0.2;
    if (self.progressView.progress>0.8) {
        self.progressView.progress=0.8;
    }
}



-(void)webViewDidFinishLoad:(UIWebView *)webView{
    self.progressView.progress=1;
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        self.progressView.hidden=YES;
    });
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
